package nieAS.utils {
	import flash.events.EventDispatcher;
	
	public class ObjectUtils {
		
		public function ObjectUtils() {
			throw new Error("ObjectUtils class is static container only");
		}
		
		public static function traceObject(obj:Object, indent:uint = 0):void {
			var indentString:String = "";
			var i:uint;
			var prop:String;
			var val:*;
			for (i = 0; i < indent; i++) {
				indentString += "\t";
			}
			for (prop in obj) {
				val = obj[prop];
				if (typeof(val) == "object") {
					trace(indentString + " " + prop + ": [Object]");
					traceObject(val, indent + 1);
				} else {
					trace(indentString + " " + prop + ": " + val);
				}
			}
		}
		
		public static function getObjectName(target:String):String {
			target = target.slice(8);
			target = target.slice(0, -1);
			return target;
		}
		
		public static function getObjectID(target:String, index:int):int {
			var _str:String = target.replace(/([ ]{1}|[\n]{1}|[a-zA-Z]|[\=\[\]]|[\{\}])/g, "");
			var _id1 = 0;
			for (var i:int = 0; i < index; i++) {
				_id1 = _str.indexOf("_", _id1);
				if (_id1 != -1) {
					_id1 += 1;
				} else {
					return -1;
				}
			}
			var _id2:int = _str.indexOf("_", _id1 + 1);
			if (_id2 == -1) {
				return int(_str.slice(_id1));
			} else {
				return int(_str.slice(_id1, _id2));
			}
		}
	}

}